package com.cyk.controller;

import com.cyk.HelloProto;
import com.cyk.HelloServiceGrpc;
import net.devh.boot.grpc.client.inject.GrpcClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @GrpcClient("grpc-server")
    private HelloServiceGrpc.HelloServiceBlockingStub stub;

    @RequestMapping("/hello")
    public String hello(String msg) {
        HelloProto.HelloRequest request = HelloProto.HelloRequest
                .newBuilder()
                .setMsg(msg)
                .build();
        HelloProto.HelloResponse response = stub.hello(request);
        return response.getResult();
    }

}
